有两个关于R的问题[s:19]
1: randomly generate 1000 pets, from the choice of "dog", "cat", "hamster" and "goldfish" and then count the number of each type of pet.
2: List the names of all the variables in the user workspace that contain the letter "a".
1: The first command should be
sample( c( "dog", "cat", "hamster", "goldfish"), size = 1000, prob=c( 0.25, 0.25, 0.25, 0.25 ) ,replace=TRUE )
BUT, how to count the number of each type of pet ? [s:12]
2: ls( ) will list all the un-hidden names. ls( pattern="a." , all.names=TRUE) will list all the names contain "a.", is this correct ?
多谢多谢!![s:11]