t.test and organizing data

#1
Hi all. I am very new - both to the forum and to R.

The issue I am having is that I want to a t.test but after trying to run a t.test and getting error messages that i am using non-integer data, I think my data might not be properly arranged. I have attached a picture of my data table.

My goal
I want to know if the land management style ("Management") which is either conventional (KONV) or at reduced intensity (VNP) results in the plants there having more protein ("Stickstoff_mg" in mg), also indicated by the percentage of raw protein as a function of biomass ("Prozent_Rohproteine"). The numbering on KONV and VNP just represent different sampling sites but the management conditions are constant across sites.

Really appreciate any help with this!

Daniel :)



1600459735086.png
 

Miner

TS Contributor
#2
I am not an R user, but those who are usually like to see your code posted, so they can see if it is a coding issue.
 
#3
Thanks, Miner :)

I checked that I have a normal distribution of all data with hist() then ran the following to try to run a t-test to find out whether KONV or VNP has a higher protein content (see previous message) and got an error message. I know that "Management" is character data and that "Prozent_Rohproteine" is numerical data and that this is important for the t.test to work but I am really unsure how to proceed. Hoping you guys can help me out!

Daniel

> t.test(Management,Prozent_Rohproteine)
Error in var(x) : Calling var(x) on a factor x is defunct.
Use something like 'all(duplicated(x)[-1L])' to test for a constant vector.
In addition: Warning message:
In mean.default(x) : argument is not numeric or logical: returning NA
>
 

Attachments

Dason

Ambassador to the humans
#4
Use.
C-like:
t.test(Prozent_Rohproteine ~ Management)
Instead. Although that only works if those are vectors in the global environment which really shouldn't be the case. Ideally these are just columns in a data.frame. in which case use

C-like:
t.test(Prozent_Rohproteine ~ Management, data = your_dataframe)